package cn.tedu.staff_user.management.dao.persist.repository.impl;

import cn.tedu.staff_user.management.dao.persist.mapper.StaffMapper;
import cn.tedu.staff_user.management.dao.persist.mapper.UserMapper;
import cn.tedu.staff_user.management.dao.persist.repository.IStaffRepository;
import cn.tedu.staff_user.management.dao.persist.repository.IUserRepository;
import cn.tedu.staff_user.management.pojo.entity.Staff;
import cn.tedu.staff_user.management.pojo.entity.User;
import cn.tedu.staff_user.management.pojo.vo.StaffListItemVO;
import cn.tedu.staff_user.management.pojo.vo.UserListItemVO;
import cn.tedu.staff_user.management.pojo.vo.UserStandardVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class UserRepositoryImpl implements IUserRepository {

    @Autowired
    private UserMapper userMapper;

/*    @Override
    public List<UserListItemVO> list() {
//        return userMapper.list();
    }*/

    @Override
    public List<User> list() {
//        return userMapper.list();
        QueryWrapper<User> objectQueryWrapper = new QueryWrapper<>();
        return userMapper.selectList(objectQueryWrapper);
    }

    @Override
    public int addNew(User user) {
        return userMapper.insert(user);
    }

    @Override
    public int countName(String username) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username", username);
        return userMapper.selectCount(queryWrapper);
    }

    @Override
    public int deleteById(Long id) {
        return userMapper.deleteById(id);
    }

    @Override
    public int updateById(User user) {
//        return userMapper.updatea(user);
        /*QueryWrapper queryWrapper=new QueryWrapper();

        int update = userMapper.update(user, queryWrapper);*/
        return userMapper.updateById(user);
    }

    /*@Override
    public int updateByUserId(Long id) {
        int update = userMapper.updateByUserId(id);
        return update;
    }*/

    @Override
    public UserStandardVO getStandardById(Long id) {
        return userMapper.getStandardById(id);
    }
}
